#include <bits/stdc++.h>
using namespace std;
long long L,R,n;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>L>>R;
	long long ol=L%n,len=R-L;
	long long ml=min(n-1,ol+len);
	printf("%lld\n",ml);
}
